/*
 * File:   Qing.h
 * Author: jcrada
 *
 * Created on 28 April 2011, 5:02 PM
 */

#ifndef ECB_QING_H
#define	ECB_QING_H

#include "ecb/base/Problem.h"


namespace ecb {

    /*
     * Source:
       @book{bf:qings-book,
      author = {Qing, Anyong},
      title = {Differential Evolution: Fundamentals and Applications in Electrical Engineering},
      year = {2009},
      publisher = {Wiley-IEEE Press}}
     */

    class Qing : public Problem {
    public:

        Qing(const std::string& id = "Qing", const std::string& name = "Qing",
                int dimensions = 0, scalar minimum = -500, scalar maximum = 500,
                bool minimization = true) :
        Problem(id, name, dimensions, minimum, maximum, minimization) { }
        scalar f(const std::vector<scalar>& x) {
            scalar result = 0;
            for (size_t i = 0; i < x.size(); ++i) {
                result += (x[i] * x[i] - i) * (x[i] * x[i] - i);
            }
            return result;
        }
    };

}

#endif	/* PSO_QING_H */

